public class StringBufferDemoTest {



        StringBuffer buffer1 = new StringBuffer("StringBuffer");
        StringBuffer buffer2 = new StringBuffer("StringBuffer123456");
        StringBuffer buffer3 = new StringBuffer("StringBuffer12345678912345678912345");
        @Test
        public void testcharAt() throws Exception {
            assertEquals('S', buffer1.charAt(0));
            assertEquals('i', buffer2.charAt(3));
            assertEquals('f', buffer3.charAt(9));
        }
        @Test
        public void testlength() throws Exception {
            assertEquals(12, buffer1.length());
            assertEquals(18, buffer2.length());
            assertEquals(35, buffer3.length());
        }
        @Test
        public void testcapacity() throws Exception {
            assertEquals(28, buffer1.capacity());
            assertEquals(34, buffer2.capacity());
            assertEquals(51, buffer3.capacity());
        }
        @Test
        public void testindexOf() throws Exception{
            assertEquals(0,buffer1.indexOf("Str"));
            assertEquals(6,buffer1.indexOf("Buf"));
        }
    }

